package net.huashitong.supervision.task.dao;

import com.sirdc.modules.core.dao.GenericQuery;
import com.sirdc.modules.core.dao.StringDao;
import net.huashitong.supervision.task.entity.TaskPermissions;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class TaskPermissionsDao extends StringDao<TaskPermissions> {

    public TaskPermissions getPermission(String userId,int type)
    {
        GenericQuery query = createQuery("obj");
        query.append(" and userId=:userId").setParam("userId",userId);
        query.append(" and types=:types").setParam("types",type);
        return query.singleResult();
    }

    public List<TaskPermissions> getListLeader(String deptId,int type){
        GenericQuery query = createQuery("obj");
        query.append(" and deptSysId=:deptSysId").setParam("deptSysId",deptId);
        query.append(" and types=:types").setParam("types",type);
        return query.listResult();
    }

}
